package logbrowse;

import java.awt.Color;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;

@SuppressWarnings("serial")
public class ViewCodeHeader extends Box {
	private JLabel date;
	private JLabel msg;
	
	public ViewCodeHeader() {
		super(BoxLayout.Y_AXIS);
		date = new JLabel(" ");
		msg = new JLabel(" ");
		add(date);
		add(msg);
	}
	
	public void setContents(LogEntry entry) {
		if (entry == null) {
			date.setText(" ");
			msg.setText(" ");
		} else {
			String dateText = entry.getDate();
			if (entry.isForced()) {
				dateText += " (forced)";
				date.setForeground(Color.RED);
			} else {
				date.setForeground(Color.BLACK);
			}
			date.setText(dateText);
			String msgText = entry.getErrorMessage();
			if (msgText == null || msgText.equals("")) {
				msgText = " ";
			}
			msg.setText(msgText);
		}
	}
}
